﻿@namespace Blazorise
@inherits BaseComponent
<Modal @ref="@ModalRef" Closing="@OnModalClosing">
    <ModalContent Centered="@CenterMessage" Scrollable="@ScrollableMessage" Size="@Size">
        <ModalHeader>
            <ModalTitle Class="@TitleClass">
                @Title
            </ModalTitle>
            @if ( ShowCloseButton )
            {
                <CloseButton Clicked="@OnCancelClicked" />
            }
        </ModalHeader>
        <ModalBody TextAlignment="TextAlignment.Center">
            @if ( ShowMessageIcon )
            {
                <Heading Size="HeadingSize.Is2" TextAlignment="TextAlignment.Center">
                    <Icon Name="@MessageIcon" TextColor="@MessageIconColor" />
                </Heading>
            }
            <Text TextAlignment="TextAlignment.Center" Class="@MessageClass">
                @Message
            </Text>
        </ModalBody>
        <ModalFooter>
            @if ( IsConfirmation )
            {
                <Button Color="@CancelButtonColor" Class="@CancelButtonClass" Padding="@CancelButtonPadding" Clicked="@OnCancelClicked">
                    @if ( Options?.CancelButtonIcon is not null )
                    {
                        <Icon Name="@Options.CancelButtonIcon" TextColor="@(Options.CancelButtonIconColor ?? TextColor.Default)" Margin="Blazorise.Margin.Is2.FromEnd" />
                    }
                    @CancelButtonText
                </Button>
                <Button Color="@ConfirmButtonColor" Class="@ConfirmButtonClass" Padding="@ConfirmButtonPadding" Clicked="@OnConfirmClicked">
                    @if ( Options?.ConfirmButtonIcon is not null )
                    {
                        <Icon Name="@Options.ConfirmButtonIcon" TextColor="@(Options.ConfirmButtonIconColor ?? TextColor.Default)" Margin="Blazorise.Margin.Is2.FromEnd" />
                    }
                    @ConfirmButtonText
                </Button>
            }
            else if ( IsChoice )
            {
                @foreach ( var choice in Choices )
                {
                    <Button @key="@choice.Key" Color="@choice.Color" Class="@choice.Class" Padding="@choice.Padding" Clicked="@(() => OnChoiceClicked( choice ))">
                        @if ( choice.Icon is not null )
                        {
                            <Icon Name="@choice.Icon" TextColor="@(choice.IconColor ?? TextColor.Default)" Margin="Blazorise.Margin.Is2.FromEnd" />
                        }
                        @choice.Text
                    </Button>
                }
            }
            else
            {
                <Button Color="@OkButtonColor" Class="@OkButtonClass" Padding="@OkButtonPadding" Clicked="@OnOkClicked">
                    @if ( Options?.OkButtonIcon is not null )
                    {
                        <Icon Name="@Options.OkButtonIcon" TextColor="@(Options.OkButtonIconColor ?? TextColor.Default)" Margin="Blazorise.Margin.Is2.FromEnd" />
                    }
                    @OkButtonText
                </Button>
            }
        </ModalFooter>
    </ModalContent>
</Modal>